
<?php
include_once  'BaseService.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/ad/sys/com/model/db/SettleDetailDAO.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/ad/sys/com/model/util/Util.php'; 

class SettleDetailService extends BaseService{
	
	function __construct() {
		parent::__construct();
	 	parent::setTarget($this);	
	}
	
	public function batchUpdate() {
	  
		$json =  $_POST["datas"];  //'{"a":{ "id": "23", "count": "0", "settle": "0", "memo": ""}, "b":{ "id": "22", "count": "0", "settle": "0", "memo": ""}}';//;'[{"a":1,"b":2,"c":3,"d":4,"e":5},{"a":1,"b":2,"c":3,"d":4,"e":5}]';
  
	    $temp = str_replace( "\\", "",$json);
	   
		$datas = Util::jsonToObject($temp);
		
		$account = $_POST["account"];
		$dao =  new SettleDetailDAO();
		$dao->batchUpdate($account,$datas);
		 
	}
	
	public function insertByAccount() {
		$account = $_GET["account"];
		$dao =  new SettleDetailDAO();
		$result = $dao->insertByAccount($account);
		echo Util::toJson($result);
	} 
	
	/**
	 * 取得使用帳務資料
	 */
	public function getSettleDetail() {
		$account = $_GET["account"];
		$dao =  new SettleDetailDAO();
		$items =  $dao->getSettleDetil($account);
		echo Util::toJson($items);
	}
}


$service =  new SettleDetailService();
$service->__call($_GET["action"], null);
?>